<%@ page import="com.gpay.erp.core.system.bean.SysUser" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<script src="<%=request.getContextPath() %>/resources/js/storage/storageManage.js"
        type="text/javascript"></script>
<script src="<%=request.getContextPath() %>/resources/js/storage/storageDocEdit.js"
        type="text/javascript"></script>
<script>
  $(function () {
    //TODO 本次已入库量
    $('#storageWeight').numberbox({
      precision: 6,
      formatter: function (value) {
        value = Math.round(parseFloat(value) * Math.pow(10, 6)) / Math.pow(10, 6);
        return formatWeight(value);
      }
    });
    refreshStorageDocEditList();
    if ($('#storageStatus').text() === "1") {
      var nodeArray = [$("#saveStorageDoc"), $("#cancelStorageDocSub")];
      setLinkButtonStatus(nodeArray, [1, 1]);
    } else {
      var nodeArray = [$("#saveStorageDoc"), $("#cancelStorageDocSub")];
      setLinkButtonStatus(nodeArray, [0, 0]);
    }
    $('#saveStorageDoc').click(function () {
      endEditing($('#subItem'));
      var subRows = $('#subItem').datagrid('getChecked');
      if (subRows.length > 0) {
        var isValid = showValidteMessage(validateDocViewBottomSubs(prepareStorageFileSubmitPostData().storageSubs));
        if (isValid) {
          postAjax("/storage/updateStorageSubList.html", JSON.stringify(prepareStorageFileSubmitRealPostData()),
                  refreshBackStorageDocEditList, {async: false, errorFunction: refreshStorageDocEditList});
        } else {
          return isValid;
        }
      } else {
        $.messager.alert('提示', '请选择要保存的的记录！', 'info');
      }
    });
    $('#cancelStorageDocSub').click(function () {
      var storageSubIds = "";
      var subRows = $('#subItem').datagrid('getChecked');
      $.each(subRows, function (index, value) {
        if (index === 0) {
          storageSubIds += value.id;
        } else {
          storageSubIds += "," + value.id;
        }
      });
      if (subRows.length > 0) {
        postAjax("/storage/deleteCancelStorageSubList.html?storageSubIds=" + storageSubIds, {},
                refreshBackStorageDocEditList, {async: false, type: 'get', errorFunction: refreshStorageDocEditList});
      } else {
        $.messager.alert('提示', '请选择要撤销的的记录！', 'info');
      }
      ;
    });
  });

</script>
<var hidden="hidden" id="storageId">${storageId}</var>
<var hidden="hidden" id="contractSubCode"></var>
<var hidden="hidden" id="resourceNumber"></var>
<var hidden="hidden" id="userId"><%=((SysUser)session.getAttribute("loginUser")).getId()%></var>
<var hidden="hidden" id="storageStatus"></var>

<div class="easyui-layout" data-options="fit : true,border : false">
  <div data-options="region:'north',title:'入库单',border : false" style="height: 120px; overflow: hidden;">
    <form id="searchForm-small">
      <div class="mLeft60">
        <div class="mTop10 line-handsome">
          <div class="fLeft label-handsome ">
            <label>入库单号:</label>
            <input id="storageCode" name="storageCode" readonly/>
          </div>
          <div class="fLeft label-handsome ">
            <label>入库类型:</label>
            <input id="storageType" name="storageType" class="easyui-input" readonly/>
          </div>
          <div class="fLeft label-handsome" id="memberNoDiv">
            <label>入库日期:</label>
            <input id="storageDate" type="text" name="storageDate" class="easyui-datebox"
                   required="required" style="width:90px"/>
          </div>
          <div class="fLeft label-handsome ">
            <label>供应商名称:</label>
            <input id="providerName" name="providerName" class="easyui-input" readonly/>
          </div>
        </div>
        <div class="mTop10 line-handsome">
          <div class="fLeft label-handsome ">
            <label>仓库名称:</label>
            <input id="warehouseName" type="text" name="warehouseName" readonly/>
          </div>
          <div class="fLeft label-handsome">
            <label>入库码单号:</label>
            <input id="storageMdCode" name="storageMdCode"/>
          </div>
          <div class="fLeft label-handsome ">
            <label>经办人:</label>
            <input id="operator" name="operator" style="width:90px" />
          </div>
          <div class="fLeft label-handsome ">
            <label>备注:</label>
            <input id="remark" name="remark" class="easyui-input"/>
          </div>
        </div>
      </div>
    </form>
  </div>
  <div data-options="region:'center',border : false,title:'采购入库明细列表'">
    <table id="subItem"></table>
  </div>
</div>